//前后端交互数据类
package com.example.communservice.util;

import lombok.Data;

@Data
public class ResponseResult {
    /**
     * 返回的code 0：成功 非0：失败
     */
    private int code;
    /**
     * 返回的提示信息
     */
    private String msg;
    /**
     * 返回的数据
     */
    private Object data;

    private ResponseResult() {

    }

    private ResponseResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private ResponseResult(int code, String msg, Object data) {
        this(code, msg);
        this.data = data;
    }

    public static ResponseResult ok() {
        return new ResponseResult(0, "处理成功");
    }

    public static ResponseResult ok(String msg) {
        return new ResponseResult(0, msg);
    }

    public static ResponseResult ok(String msg, Object data) {
        return new ResponseResult(0, msg, data);
    }

    public static ResponseResult error() {
        return new ResponseResult(1, "处理失败");
    }

    public static ResponseResult error(String msg) {
        return new ResponseResult(1, msg);
    }

    public static ResponseResult error(int code, String msg) {
        return new ResponseResult(code, msg);
    }
}
